ajax({
    method: 'GET', //请求方法
    url: 'http://www.xiongmaoyouxuan.com/api/tab/1?start=0', //url地址
    success: function (data) {
        console.log(data);
        if (data.code == 200) {
            //处理成功数据 data
            let list = data.data.items.list
            // let num = list.length % 4
            // if (num != 0) {
            //     list.splice(list.length - num, num)
            // }
            console.log(list);
            productList(list)
        }
    }
})
//渲染页面
let ulObj = document.querySelector('ul[class="product-list-li"]')
function productList(list) {
    list.forEach(function (v, i) {
        let str = `
    <div class="img"><img src=${v.image} alt=""></div>
    <div class="describe">${v.title}</div>
    <div class="titie">
        <div class="titie-l">淘宝</div>
        <div class="titie-r">包邮</div>
    </div>
    <div class="price">
        <div class="price-l">
            <span class="a">￥</span>
            <span class="b">${v.price}</span>
    
            <span class="d">${v.saleNum}已买</span>
        </div>
        <div class="price-r">
          ${v.couponValue}
        </div>
    </div>
    `
        let objLi = document.createElement('li')
        let id = v.id
        objLi.innerHTML = str
        ulObj.appendChild(objLi)
        // //点击商品跳转商品详情页
        // details(objLi, id)

    })
}
let index=document.querySelector('.menu .a')
console.log(index);
let nine=document.querySelector('.menu .b')
let cool=document.querySelector('.menu .c')
index.onclick=function(){
    location.href="../pages/index.html"
}
nine.onclick=function(){
    location.href="../pages/nine.html"
}
cool.onclick=function(){
    location.href="../pages/cool.html"
}